/*
  Copyright (c) 2010 Les Newell. All rights reserved

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/*
Kinematics base class.
Kinematics modules convert flight control pitch, yaw, roll and throttle commands
to motor and servo commands.
*/

DEFINE_MODULE(Kinematics,Module)
//Note the lack of an opening curly bracket.


    //Only use this to expose sockets and parameters. Do most of your
    //initialisastion in Init()
    Kinematics()
    {
    }

    //A parameter has changed. This happens at bootup if the EEPROM
    //contains valid data and at run-time if the user changes a
    //parameter over the serial link
    virtual void ParamChanged(Socket * param)
    {
    }

    //Initialise the module
    //set up hardware etc
    //NOTE: You must call Kinematics::Init() from your INit() function
    virtual void Init()
    {
        m_commands[PITCH].Connect("FlightControl.Pitch");
        m_commands[ROLL].Connect("FlightControl.Roll");
        m_commands[YAW].Connect("FlightControl.Yaw");
        m_commands[THROTTLE].Connect("FlightControl.Throttle");
        m_flightMode.Connect("FlightMode.Status");
    }

    //Here is where you do your work. It is called at the rate defined by SetInterval
    virtual void Loop(const unsigned long& interval)
    {
    }

protected:
    Plug8 m_flightMode;
    PlugF m_commands[MAX_COMMANDS];
};

